<html>
<body>

<form action="" onsubmit="return false;">
	Password input : <input type="password" id="testPassword" style="width:300px" /><br />
	Visible password input : <input type="text" id="visiblePassword" style="width:300px" /><br />
</form>


<div id="log" style="float:left; width:200px; height: 200px; overflow:auto; border:1px solid black; padding:5px;">
Listened by password field
</div>


<div id="log2" style="float:left; width:200px; height: 200px; overflow:auto; border:1px solid black; padding:5px;">
Listened by window
</div>

<script type="text/javascript">

var testPassword = document.getElementById('testPassword');
var log = document.getElementById('log');
var log2 = document.getElementById('log2');
var appendLog = function (line) {
	log.innerHTML += line + '<br/>';
	//if (console) console.log('[test_hooker.html] INPUT ' + line);
	log.scrollTop = log.scrollHeight;
}
var appendLog2 = function (line) {
	log2.innerHTML += line + '<br/>';
	//if (console) console.log('[test_hooker.html] WINDOW ' + line);
	log2.scrollTop = log2.scrollHeight;
}

testPassword.focus();

setInterval(function () {
	document.getElementById('visiblePassword').value = testPassword.value;
}, 1000);

testPassword.addEventListener('textinput', function (ev) {
	appendLog(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
testPassword.addEventListener('keyup', function (ev) {
	appendLog(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
testPassword.addEventListener('keydown', function (ev) {
	//console.log(ev);
	appendLog(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
testPassword.addEventListener('keypress', function (ev) {
	if (ev.keyCode == 0) {
		appendLog(ev.type + ': ' + String.fromCharCode(ev.charCode));
	} else {
		appendLog(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
	}
}, true);

window.addEventListener('textinput', function (ev) {
	appendLog2(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
window.addEventListener('keyup', function (ev) {
	appendLog2(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
window.addEventListener('keydown', function (ev) {
	appendLog2(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
}, true);
window.addEventListener('keypress', function (ev) {
	if (ev.keyCode == 0) {
		appendLog2(ev.type + ': ' + String.fromCharCode(ev.charCode));
	} else {
		appendLog2(ev.type + ': ' + ev.keyCode + ' ' + String.fromCharCode(ev.keyCode));
	}
}, true);

</script>
</body>
</html>